package com.yunpuvip.sachet.controller;

import com.yunpuvip.sachet.biz.entity.GiftInfo;
import com.yunpuvip.sachet.biz.model.params.GiftInfoParam;
import com.yunpuvip.sachet.biz.service.GiftInfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.yunpuvip.sachet.modular.page.LayuiPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 赠送信息控制器
 *
 * @author griftt
 * @Date 2019-08-27 20:54:12
 */
@Controller
@RequestMapping("/giftInfo")
public class GiftInfoController extends BaseController {

    private String PREFIX = "/modular/giftInfo";

    @Autowired
    private GiftInfoService giftInfoService;

    /**
     * 跳转到主页面
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/giftInfo.html";
    }

    /**
     * 新增页面
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/giftInfo_add.html";
    }

    /**
     * 编辑页面
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/giftInfo_edit.html";
    }

    /**
     * 新增接口
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(GiftInfoParam giftInfoParam) {
        this.giftInfoService.add(giftInfoParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(GiftInfoParam giftInfoParam) {
        this.giftInfoService.update(giftInfoParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(GiftInfoParam giftInfoParam) {
        this.giftInfoService.delete(giftInfoParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(GiftInfoParam giftInfoParam) {
        GiftInfo detail = this.giftInfoService.getById(giftInfoParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author griftt
     * @Date 2019-08-27
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(GiftInfoParam giftInfoParam) {
        return this.giftInfoService.findPageBySpec(giftInfoParam);
    }

}


